﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace canyinguanlixitong
{
    public partial class frmas1qw4 : Form
    {
        public frmas1qw4()
        {
            InitializeComponent();
        }
        string str = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void button2_Click(object sender, EventArgs e)
        {
            add();
        }
        //查询
        public void add() {
            SqlConnection conn = new SqlConnection(str);
            DataSet ds = new DataSet("Stu");
            string sql = @"select spName,spJia,slLei,userName,zxfID,xfTime,userDian,xfZong,fangJai
 from dbo.commodity,[Commodity type],dbo.UserTpye,Consumption,[Summary of consumption]
where commodity.spLei=[Commodity type].SlId and UserTpye.userID=Consumption.xfID 
and [Summary of consumption].xfID=Consumption.xfID and zxfID like'%"+this.txtzhangdanhao.Text+"%'";
            SqlDataAdapter asdf = new SqlDataAdapter(sql,conn);
            asdf.Fill(ds,"Stu");
            dataGridView1.DataSource = ds.Tables["Stu"];
        }

      

        private void txtzhangdanhao_TextChanged(object sender, EventArgs e)
        {
            add();
        }
    }
}
